/*****************************************************************
 MYD Engine v0.1

 File: myd_entity.cpp
 Created: 12/06/09
*****************************************************************/
#include "myd_entity.h"
#include "graphics/myd_renderer.h"

using namespace myd;
//----------------------------------------------------------------
Entity::Entity (Renderer *renderer):
				m_kName(""),
				m_fX(0), 
				m_fY(0), 
				m_fW(1),
				m_fH(1),
				m_fL(1),
				m_fRotationX(0),
				m_fRotationY(0),
				m_fRotationZ(0),
				m_fMovSpeed(0),
				m_fMovAngle(0),
				m_fMovAngleRad(0),
				isMoving(false),
				renderer(renderer)
{
}
//----------------------------------------------------------------
void Entity::draw()
{
	// set the world matrix
	renderer->setMatrixMode(WORLD);

	// reset the matrix
	renderer->loadIdentity();

	// apply transformation
	renderer->translate(m_fX, m_fY);
	renderer->rotateX(m_fRotationX * 3.14159f / 180.0f);
	renderer->rotateY(m_fRotationY * 3.14159f / 180.0f);
	renderer->rotateZ(m_fRotationZ * 3.14159f / 180.0f);
	renderer->scale(m_fW, m_fH, m_fL);
}
//----------------------------------------------------------------
void Entity::update (float fTimeBetweenFrames)
{
	if (isMoving)
	{
		m_fX += (fTimeBetweenFrames / 1000.0f) * m_fMovSpeed * cos(m_fMovAngleRad);
		m_fY += (fTimeBetweenFrames / 1000.0f) * m_fMovSpeed * sin(m_fMovAngleRad);
	}
}
//----------------------------------------------------------------
void Entity::onCollide(Entity* tm_entity)
{
	
}